{% extends "../public/basechild.html" %}

{% block title %} 权限配置 {% endblock title %}

{% block style %}
<link href="/static/admin/adminex/css/style.css" rel="stylesheet">
<link href="/static/admin/hui/static/h-ui/css/H-ui.css" rel="stylesheet">
<link href="/static/admin/hui/lib/Hui-iconfont/1.0.7/iconfont.css" rel="stylesheet">
{% endblock style %}

{% block content %}
<section style="padding: 10px;">
	<div class="row">
		<div class="col-sm-12" style="margin: 15px 0;">			
			<span class="btn btn-success radius" onclick="add(0)"><i class="Hui-iconfont">&#xe600;</i>&nbsp;新增板块</span>
			<span class="btn btn-secondary radius" style="float: right;" onclick="refresh()"><i class="Hui-iconfont">&#xe68f;</i>&nbsp;刷新页面</span>
		</div>
		<div class="col-sm-12">
			<ul id="Huifold1" class="Huifold">
			{% for item in list %}

				{% if item.category===3 %}

				<li class="item">
					<h4>{{item.name}}<b>+</b></h4>
					<div class="info">
<div class="btn-group" style="width: 100%">
	<span class="btn btn-success" onclick="edit({{item.id}}, 1)"><i class="Hui-iconfont">&#xe604;</i>&nbsp;权限</span>
	<span class="btn btn-warning" onclick="add({{item.id}})"><i class="Hui-iconfont">&#xe6df;</i>&nbsp;编辑</span>
	<span class="btn btn-danger" onclick="del({{item.id}})"><i class="Hui-iconfont">&#xe6e2;</i>&nbsp;板块</span>
</div>
						{% for opt in list %}

							{% if opt.pid===item.id %}
							<div class="btn-group" style="margin-right: 10px;margin-top: 10px;">
								<span class="btn radius" onclick="edit({{opt.id}}, 2)">{{opt.name}}</span>
								<span class="btn btn-danger radius" onclick="del({{opt.id}})"><i class="Hui-iconfont">&#xe609;</i></span>
							</div>
							{% endif %}

						{% endfor %}

					</div>
				</li>

				{% endif %}

			{% endfor %}
			</ul>
		</div>
	</div>
</section>
{% endblock content%}

{% block script%}
<script src="/static/admin/js/jquery.min.js"></script>
<script src="/static/admin/hui/static/h-ui/js/H-ui.js"></script>
<script src="/static/admin/layer/layer.js"></script>
<script src="/static/admin/js/h.js"></script>
<script src="/static/admin/js/ajax.js"></script>
<script>
$(function(){
	$.Huifold("#Huifold1 .item h4","#Huifold1 .item .info","fast",1,"click");
	/*5个参数顺序不可打乱，分别是：相应区,隐藏显示的内容,速度,类型,事件*/
});

// 添加权限板块和编辑权限板块
function add(pid){
	if (pid) {
		H.ajaxiframe('/admin/quanxian/add?pid='+pid+'&ct=3',400,200,'编辑权限板块');
	} else {
		H.ajaxiframe('/admin/quanxian/add?pid=0&ct=3',400,200,'添加权限板块');
	}
}

function edit(id, tp){
	if (tp === 1) {
		H.ajaxiframe('/admin/quanxian/editor?id='+id+'&tj=1&ct=4',400,400,'添加权限');
	} else {
		H.ajaxiframe('/admin/quanxian/editor?id='+id+'&tj=0&ct=4',400,400,'编辑权限');
	}
	

}
function del(id){
	layer.confirm('确定删除当前权限？', function(){
		H.ajax('/admin/quanxian/del',{id: id},'post',function(data){
			layer.msg(data.data, {icon:1, time:2000});
			setTimeout(refresh, 2000);
		})
	})

}

function refresh(){
	window.location.reload();
}
</script>
{% endblock script%}